package com.example.controller;


import com.example.common.utils.R;
import com.example.system.entity.Like;
import com.example.system.service.ILikeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王鹤蒲
 * @since 2023-09-07
 */
@RestController
@Api(value = "", tags = {""})
@RequestMapping("/like")
        public class LikeController {

    @Autowired
    private ILikeService iLikeService;

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/save" , method = RequestMethod.POST)
    @ResponseBody
    public R saveLike(@RequestBody Like like){
            return iLikeService.saveLike(like);
            }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/edit" , method = RequestMethod.POST)
    @ResponseBody
    public R updateLike(@RequestBody Like like){
            return iLikeService.updateLike(like);
            }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/delete/{id}" , method = RequestMethod.DELETE)
    @ResponseBody
    public R deleteById(@PathVariable("id") Integer id){
            return iLikeService.deleteById(id);
            }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/deleteBatch" , method = RequestMethod.POST)
    @ResponseBody
    public R deleteByIds(@RequestBody Integer[]ids){
            return iLikeService.deleteByIds(ids);
            }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/page" , method = RequestMethod.GET)
    @ResponseBody
    public R findPage(@RequestParam int currentPage,@RequestParam int pageSize,@RequestParam(defaultValue = "")String name){
            return iLikeService.findPage(currentPage,pageSize,name);
            }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/{id}" , method = RequestMethod.GET)
    @ResponseBody
    public R findOne(@PathVariable("id") Integer id){
            return iLikeService.findOne(id);
            }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/findAll" , method = RequestMethod.GET)
    @ResponseBody
    public R findAll(){
            return iLikeService.findAll();
            }

    

        }

